﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Management;
using System.Text;
using WMI.NET.Abstracts;
using WMI.NET.CIM;

namespace WMI.NET.ComputerSystemHardware.MotherboardControllerPort
{
    /// <summary>
    /// The Win32_PnPAllocatedResource association WMI class represents an association between logical devices and system resources. This class is used to discover the resources that are in-use by a specific device, such as an Interrupt ReQuest (IRQ) or a Direct Memory Access (DMA) channel. 
    /// </summary>
    public class Win32_PnPAllocatedResource : CIM_AllocatedResource
    {

        /// <summary>
        /// 
        /// </summary>
        /// <param name="mbo"></param>
        public Win32_PnPAllocatedResource(ManagementBaseObject mbo)
            : base(mbo)//TODO must fix bugs
        {

        }

    }

    /// <summary>
    /// 
    /// </summary>
    public class GetWin32_PnPAllocatedResources : Win32Collection<Win32_PnPAllocatedResource> 
    {

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override ReadOnlyCollection<Win32_PnPAllocatedResource> GetCollection()
        {
            List<Win32_PnPAllocatedResource> tempCollection = new List<Win32_PnPAllocatedResource>();

            foreach (var s in searcher.Get())
            {
                Win32_PnPAllocatedResource tempListItem = new Win32_PnPAllocatedResource(s);
                tempCollection.Add(tempListItem);
            }

            return tempCollection.AsReadOnly();
        }

        /// <summary>
        /// 
        /// </summary>
        public GetWin32_PnPAllocatedResources() : base("SELECT * FROM Win32_PnPAllocatedResource") { }

    }

}
